#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int game(){
    int x=0;
    int ret=0;
    ret=rand()%100+1;
    while(1){
        printf("请输入您猜的数:\n");
        scanf("%d",&x);
        if(x<ret){
            printf("猜小了\n");
        }
        else if(x>ret){
            printf("猜大了\n");
        }
        else{
            printf("恭喜你，猜对了\n");
            break;
        }
    }
    return 0;
}

int main(){
    int ip;
    srand((unsigned int)time(NULL));
    do{
        printf("输入1开始游戏，输入0退出游戏\n");
        scanf("%d",&ip);
        switch(ip){
            case 1:
                game();
                break;
            case 0:
                printf("游戏结束\n");
                break;

            default:
                printf("输入错误\n");
                break;

        }
    }
    while(ip);
    return 0;
}


//